#ifndef UI_BUTTON_H
#define UI_BUTTON_H

#include "UIWidget.h"

class UIButton : public UIWidget
{
public:
	UIButton();
	virtual ~UIButton();

	static UIButton* create(const char* normalFile, const char* selectedFile=NULL, const char* disabledFile=NULL, CCObject* target=NULL, SEL_MenuHandler selector=NULL);
	virtual bool initWithNormalImage(const char* normalFile, const char* selectedFile=NULL, const char* disabledFile=NULL, CCObject* target=NULL, SEL_MenuHandler selector=NULL);

	void registerScriptActiveHandler(int nHandler);

	void unregisterScriptActiveHandler(void);
	/** Activate the button */
	virtual void activate();
	/** set the target/selector of the button*/
	void setTarget(CCObject *rec, SEL_MenuHandler selector);
protected:
	virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);
	virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent);
	virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);

	virtual void draw();
protected:
	CC_SYNTHESIZE_RETAIN(CCSprite*, m_pNormalSprite, NormalSprite);
	CC_SYNTHESIZE_RETAIN(CCSprite*, m_pSelectedSprite, SelectedSprite);
	CC_SYNTHESIZE_RETAIN(CCSprite*, m_pDisabledSprite, DisabledSprite);
	CC_SYNTHESIZE_PASS_BY_REF(bool, m_bSelected, Selected);
	CC_SYNTHESIZE_PASS_BY_REF(bool, m_bCheckable, Checkable);
	CC_SYNTHESIZE_PASS_BY_REF(bool, m_bChecked, Checked);

protected:
	CCObject*			m_pListener;
	SEL_MenuHandler		m_pfnSelector;
	int					m_nActiveHandler;
};

#endif